package com.assisjrs.jpaandroid.persistence.converter;

import java.util.HashMap;
import java.util.Map;

import com.assisjrs.jpaandroid.persistence.ConverterDatabase;
import com.assisjrs.jpaandroid.persistence.ConverterFactory;
import com.assisjrs.jpaandroid.persistence.FieldType;

public class ConverterFactoryImpl implements ConverterFactory {
	private final Map<FieldType, ConverterDatabase<?, ?>> mapConverter = new HashMap<FieldType, ConverterDatabase<?, ?>>();

	public ConverterFactoryImpl() {
		mapConverter.put(FieldType.BIG_INTEGER, new BigIntegerConverter());
		mapConverter.put(FieldType.BIG_DECIMAL, new BigDecimalConverter());
		mapConverter.put(FieldType.LONG, new LongConverter());
		mapConverter.put(FieldType.DOUBLE, new DoubleConverter());
		mapConverter.put(FieldType.FLOAT, new FloatConverter());
		mapConverter.put(FieldType.INTEGER, new IntegerConverter());
		mapConverter.put(FieldType.SHORT, new ShortConverter());
		mapConverter.put(FieldType.BYTE, new ByteConverter());
		mapConverter.put(FieldType.CHARACTER, new CharacterConverter());
		mapConverter.put(FieldType.BOOLEAN, new BooleanConverter());
		mapConverter.put(FieldType.ENUM, new EnumConverter());
		mapConverter.put(FieldType.DATE, new DateConverter());
		mapConverter.put(FieldType.TIME, new TimeConverter());
		mapConverter.put(FieldType.TIMESTAMP, new TimestampConverter());
		mapConverter.put(FieldType.STRING, new StringConverter());
		mapConverter.put(FieldType.BLOB, new BlobConverter());
		mapConverter.put(FieldType.ONE_TO_MANY, new OneToManyConverter());
		mapConverter.put(FieldType.ONE_TO_ONE, new OneToOneConverter());
		mapConverter.put(FieldType.MANY_TO_ONE, new ManyToOneConverter());
		mapConverter.put(FieldType.MANY_TO_MANY, new ManyToManyConverter());
	}

	public ConverterDatabase<?, ?> getConverter(final FieldType fieldType) {
		return mapConverter.get(fieldType);
	}
}
